/// @tags: SAM String
#include <algorithm>
#include <cstdio>
#include <cstring>

int const N = 2e6 + 5;

struct Edge {
  int v, nxt;
} e[N << 1];

struct Node {
  int ch[26], len, link;
} sam[N];

int n, las, e_cnt, tot;
int heads[N];
char str[N];
long long ans, val[N];

inline void add(int u, int v) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt;
}

inline void insert(int c) {
  int cur = ++tot, pos = las;
  val[tot] = 1;
  sam[0].link = -1;
  sam[cur].len = sam[pos].len + 1;
  while (~pos && !sam[pos].ch[c]) {
    sam[pos].ch[c] = cur;
    pos = sam[pos].link;
  }
  if (pos == -1) {
    sam[cur].link = 0;
  } else {
    int q = sam[pos].ch[c];
    if (sam[q].len == sam[pos].len + 1) sam[cur].link = q;
    else {
      int clone = ++tot;
      sam[clone] = sam[q];
      sam[clone].len = sam[pos].len + 1;
      sam[q].link = sam[cur].link = clone;
      while (~pos && sam[pos].ch[c] == q) {
        sam[pos].ch[c] = clone;
        pos = sam[pos].link;
      }
    }
  }
  las = cur;
}

void dfs(int x) {
  for (int i = heads[x]; i; i = e[i].nxt) {
    dfs(e[i].v);
    val[x] += val[e[i].v];
  }
  if (val[x] != 1) ans = std::max(ans, val[x] * sam[x].len);
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("SuffixAutoMaton.in", "r", stdin);
  freopen("SuffixAutoMaton.out", "w", stdout);
#endif
#endif

  scanf("%s", str);
  n = strlen(str);
  for (int i = 0; i < n; ++i) insert(str[i] - 'a');
  for (int i = 1; i <= tot; ++i) add(sam[i].link, i);
  dfs(0);
  printf("%lld", ans);
  return 0;
}